home *** CD-ROM | disk | FTP | other *** search
- /*
- * Forger
- * An init for forcing AOCE digital signitures to always succeed or fail.
- *
- * Copyright © 1993 by David Shayer. All rights reserved.
- *
- * File: Control.c
- */
-
-
- /***************************** Includes *******************************/
-
- #include <Traps.h>
-
- #include "Control.h"
-
-
- /***************************** Globals *******************************/
-
- DataRecPtr gDataPtr;
-
- /***************************** Routines *******************************/
-
- void main (void)
- {
- Init();
- CheckOCE();
- gDataPtr=GetDataAddr ();
- HandleDialog();
- }
-
-
- void Init (void)
- {
- MaxApplZone();
- InitGraf(&thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NULL);
- FlushEvents(everyEvent,0);
- }
-
-
- // check for digital sigs, the quick and dirty way
- void CheckOCE (void)
- {
- long UnimpAddr, DigSigAddr;
-
- DigSigAddr = NGetTrapAddress (_DigitalSignature, ToolTrap);
- UnimpAddr = GetTrapAddress (_Unimplemented);
- if (UnimpAddr==DigSigAddr)
- {
- Alert (128, NULL);
- ExitToShell ();
- }
- }
-
- void HandleDialog (void)
- {
- DialogPtr DPtr;
- short item;
- Rect rect;
- Handle hdl;
- GDHandle gdh;
-
- gdh = GetMainDevice();
- if ((**((**gdh).gdPMap)).pixelSize>=4)
- DPtr=GetNewDialog (rMainDlog, NULL, (WindowPtr)-1);
- else
- DPtr=GetNewDialog (rBWMainDlog, NULL, (WindowPtr)-1);
-
- GetDItem (DPtr, rRect1, &item, &hdl, &rect);
- SetDItem (DPtr, rRect1, item, DrawRect, &rect);
- GetDItem (DPtr, rRect2, &item, &hdl, &rect);
- SetDItem (DPtr, rRect2, item, DrawRect, &rect);
- if (gDataPtr->On)
- GetDItem (DPtr, rOn, &item, &hdl, &rect);
- else
- GetDItem (DPtr, rOff, &item, &hdl, &rect);
- SetCtlValue (hdl,1);
- if (gDataPtr->Succeed)
- GetDItem (DPtr, rAlways, &item, &hdl, &rect);
- else
- GetDItem (DPtr, rNever, &item, &hdl, &rect);
- SetCtlValue (hdl,1);
-
- do
- {
- ModalDialog (NULL, &item);
- switch (item)
- {
- case rAbout:
- AboutBox ();
- break;
- case rOn:
- GetDItem (DPtr, rOn, &item, &hdl, &rect);
- SetCtlValue (hdl,1);
- GetDItem (DPtr, rOff, &item, &hdl, &rect);
- SetCtlValue (hdl,0);
- gDataPtr->On=1;
- break;
- case rOff:
- GetDItem (DPtr, rOn, &item, &hdl, &rect);
- SetCtlValue (hdl,0);
- GetDItem (DPtr, rOff, &item, &hdl, &rect);
- SetCtlValue (hdl,1);
- gDataPtr->On=0;
- break;
- case rAlways:
- GetDItem (DPtr, rAlways, &item, &hdl, &rect);
- SetCtlValue (hdl,1);
- GetDItem (DPtr, rNever, &item, &hdl, &rect);
- SetCtlValue (hdl,0);
- gDataPtr->Succeed=1;
- break;
- case rNever:
- GetDItem (DPtr, rAlways, &item, &hdl, &rect);
- SetCtlValue (hdl,0);
- GetDItem (DPtr, rNever, &item, &hdl, &rect);
- SetCtlValue (hdl,1);
- gDataPtr->Succeed=0;
- break;
- default:
- break;
- }
- }
- while (item!=rQuit);
- DisposDialog (DPtr);
- }
-
-
- void AboutBox (void)
- {
- GDHandle gdh;
-
- gdh = GetMainDevice();
- if ((**((**gdh).gdPMap)).pixelSize>=4)
- Alert (rColorAbout, NULL);
- else
- Alert (rBWAbout, NULL);
- }
-
-
- DataRecPtr GetDataAddr (void)
- {
- DataRecPtr DataPtr;
-
- asm
- {
- MOVE.L #kControlAddr, D0
- DC.W _DigitalSignature
- MOVE.L D0, DataPtr
- }
- return DataPtr;
- }
-
-
- pascal void DrawRect (WindowPtr WindPtr, short ItemNo)
- {
- short Item;
- Handle ItemHdl;
- Rect ItemRect;
-
- GetDItem (WindPtr, ItemNo, &Item, &ItemHdl, &ItemRect);
- FrameRect (&ItemRect);
- }
-
-
-